package com.atguigu.gmall;

import org.csource.fastdfs.*;
import org.springframework.util.ClassUtils;

/**
 * @author: 李旭
 * @create: 2021-07-05 15:29
 *
 *   测试文件系统的
 **/
public class FastDFSDemo {

    public static void main(String[] args) throws Exception{

       // D:\IdeaProjects\gmall-210111\gmall-parent\service
       //\service-product\src\main\resources\fdfs_client.conf
        //FastDFSDemo.class.getClassLoader().getResource("fdfs_client.conf")
        String path = ClassUtils.class.getClassLoader().getResource("fdfs_client.conf").getPath();
        System.out.println("path:" + path);
        //0:加载客户端的配置文件  IO流 只认绝对路径 不认相对路径
        ClientGlobal.init(path);
        //1:连接Tracker服务器
        TrackerClient trackerClient = new TrackerClient();
        //2:连接Tracker
        TrackerServer trackerServer = trackerClient.getConnection();
        //3:升级版的StorageClient1
        StorageServer storageServer = null;//扩展
        StorageClient1 storageClient1 = new StorageClient1(trackerServer,storageServer);
        //4:上传文件
        String file_id = storageClient1.upload_file1(
                "D:\\尚品汇商城\\资料\\图片\\Apple11\\5f7eafcd01dd2304.jpg",
                "jpg", null);

        System.out.println("file_id:" + file_id);
        //  http://192.168.200.138:8080/ group1/M00/00/00/wKjIimDjKtiABiq_AAT8_AoEzOU779.jpg


    }
}
